/**
 * Created by szc on 2016/12/29.
 */

class NumPanel2 extends egret.DisplayObjectContainer {
    private interval = 10;
    // 设计将每个数字的长高
    private numWidth:number;
    private numHeight:number;
    private num:number;
    private style:string;
    private group= new egret.DisplayObjectContainer();

    private bitMapFont:eui.BitmapLabel

    public constructor(numWidth:number,numHeight:number,style:string) {
        super();
        this.numWidth = numWidth;
        this.numHeight = numHeight;
        this.style = style;
        this.bitMapFont = new eui.BitmapLabel();
        this.bitMapFont.font = RES.getRes("numberFont_fnt");
        this.bitMapFont.$setTextAlign("center")
        this.bitMapFont.$setScaleX(0.5);
        this.bitMapFont.$setScaleY(0.5);
        this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
    }
    



    private onAddToStage(event: egret.Event) {
        //this.draw();
        this.addChild(this.bitMapFont);
        this.removeEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
    }




    /**
     * 获取数
     * @returns {number}
     */
    public getNum():any{
        return this.num;
    }

    /**
     * 设置数
     * @param num
     */
    public setNum(num:any):void{
         num = num*1;
         this.num = num;
         this.bitMapFont.$setText(num);
         this.bitMapFont.$setAnchorOffsetX(this.bitMapFont.$getWidth()/2);
         this.bitMapFont.$setAnchorOffsetY(this.bitMapFont.$getHeight()/2);
    }

    public setScale(scale:number)
    {
        this.bitMapFont.$setScaleX(scale);
        this.bitMapFont.$setScaleY(scale);
    }

    // /**
    //  * 绘制当前的面板
    //  */
    // private draw():void{

    //     this.closeDrawPanle();

    //     var numArr  = this.num.toString();
    //     for(var i = 0;i<numArr.length;i++) {
    //     // for(var i = numArr.length-1;i>-1;i--) {
    //         var img = this.getOneNum(numArr[numArr.length-i-1]);
    //         img.x = -((i+1)*this.numWidth);
    //         this.group.addChild(img);
    //         // console.log(i,numArr[i]);
    //     }
    //     this.addChild(this.group);
    // }

    // /**
    //  * 获取创建单个数字的指针
    //  * @param num
    //  * @returns {ImageBitmap}
    //  */
    // private  getOneNum(num:any):any{
    //     var imgCon = [];
    //     imgCon['url'] = this.style+num+"_png";
    //     imgCon['width'] = this.numWidth;
    //     imgCon['height'] = this.numHeight;
    //     var img = new ImageBitmap(imgCon);
    //     return img.getImgPoint();
    // }

    // private closeDrawPanle(){
    //     if(this.contains(this.group)){
    //         this.removeChild(this.group);
    //     }
    //     this.group = new egret.DisplayObjectContainer();
    // }


}